USE [texchange_db]
GO

/****** Object:  UserDefinedFunction [dbo].[Fn_GetUniversalType]    Script Date: 05/29/2011 20:00:13 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE FUNCTION [dbo].[Fn_GetUniversalType] 
(	
	-- Add the parameters for the function here
	@id  bigint=0
)
RETURNS TABLE 
AS
RETURN 
(
	-- Add the SELECT statement with parameter references here
	SELECT [UniversalType].[id], [UniversalType].[name], [UniversalType].[language_id], [UniversalType].[type_id], 
	[UniversalType].[isActive],[UniversalType].[parent_id], utype.name as parent_name from UniversalType
	LEFT JOIN UniversalType as utype on utype.id=UniversalType.parent_id
	 WHERE UniversalType.id=@id
)

GO


